<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('咨询列表')"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="type-form">
                <div class="select-list">
                    <ul>
                        <li>
                            发布对象：<input type="text" name="release"/>
                        </li>
                        <li>
                            咨询类型：<select name="cloumnCode">
                            <option value="">所有</option>
                            <option value="FA">找方案</option>
                            <option value="XQ">发需求</option>
                            <option value="ZJ">找专家</option>
                            <option value="WT">提问题</option>
                        </select>
                        </li>
                        <li>
                            标题/专家姓名：<input type="text" name="title"/>
                        </li>
                        <li>
                            产业分类：<select name="industry">
                            <option value="">所有</option>
                            <option th:each="tag : ${tags}" th:text="${tag.tagName}" th:value="${tag.tagName}"></option>
                        </select>
                        </li>
                        <li>
                            状态：<select name="status">
                            <option value="">所有</option>
                            <option value="1">启用</option>
                            <option value="0">禁用</option>
                        </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.addnoticFull()" shiro:hasPermission="system:business:add">
                <i class="fa fa-plus"></i> 添加信息
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:business:edit')}]];
    var listFlag = [[${@permission.hasPermi('system:business:list')}]];
    var removeFlag = [[${@permission.hasPermi('system:business:remove')}]];
    var prefix = ctx + "system/business";

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/detail/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            detailUrl: prefix + "/detail/{id}",
            sortName: "createTime",
            sortOrder: "desc",
            modalName: "咨询管理",
            columns: [
            {
                field: 'id',
                title: '序号'
            },
            {
                field: 'release',
                title: '发布对象',
                sortable: false
            },
            {
                field: 'cloumnName',
                title: '咨询类型',
                sortable: false
            },
            {
                field: 'title',
                title: '标题/专家名称'
            },
             {
                field: 'industry',
                title: '产业分类'
            },
            {
                field: 'price',
                title: '意向金额'
            },
            {
                field: 'status',
                title: '状态',
                formatter: function (value, row, index) {
                                        return statusTools(row);
                                 }
            },
            {
                field: 'createTime',
                title: '上报时间',
                sortable: false
            },
            {
                title: '操作',
                align: 'center',
                formatter: function(value, row, index) {
                    var actions = [];
                    if(row.status == 1){
                        actions.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)" data-id="'+row.id+'" onclick="updateStatus(\'' + row.id + '\')"><i class="fa fa-times"></i>停用</a> ');
                    }else{
                        actions.push('<a class="btn btn-primary btn-xs " href="javascript:void(0)" data-id="'+row.id+'" onclick="updateStatus(\'' + row.id + '\')"><i class="fa fa-check"></i>启用</a> ');
                    }
                    actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="details(\'' + row.id + '\')"><i class="fa fa-edit"></i>详情</a> ');
                    return actions.join('');
                }
            }]
        };
        $.table.init(options);
    });

    /*字典列表-详细*/
    function detail(id) {
        var url = prefix + '/detail/' + id;
        $.modal.openTab("标签数据", url);
    }

    function statusTools(row) {
		    if (row.status == 1) {
    			return '正常';
    		} else {
    			return '禁用';
    		}
		}

    function updateStatus(data){
        $.operate.get(prefix + "/status?id=" + data);
    }

    function details(data){
        $.modal.openFull("咨询详情",prefix + "/detail/" + data);
    }
</script>
</body>
</html>